﻿@inherits BaseComponent

<CmsCard Class="cl-bbs-menu">
    <div style="margin-bottom:10px;">
        <AntButton Name="去提问" Block OnClick="location='./bbs/postform'" />
    </div>
    <a href="@Url.UserCreatorUrl" class="@(IsActive("")?"active":"")">
        <i class="far fa-home" />
        <span style="margin-left:10px;">首页</span>
    </a>
    <a href="@Url.UserPostsUrl" class="@(IsActive("posts")?"active":"")">
        <i class="far fa-list-alt" />
        <span style="margin-left:10px;">问题管理</span>
    </a>
    <a href="@Url.UserRepliesUrl" class="@(IsActive("replies")?"active":"")">
        <i class="far fa-comment-alt-dots" />
        <span style="margin-left:10px;">回答管理</span>
    </a>
</CmsCard>

@code {
    private bool IsActive(string code)
    {
        var uri = Navigation.Uri.Split('?')[0];
        if (code == "" && uri.EndsWith("/creator"))
            return true;

        return uri.EndsWith($"/creator/{code}");
    }
}